const mongoose = require('mongoose');

const messageSchema = new mongoose.Schema({
    type: {
        type: String,
        enum: ['group', 'private'],
        required: true
    },
    from: {
        userId: String,
        username: String
    },
    to: {
        userId: String,
        username: String
    },
    content: String,
    file: {
        filename: String,
        originalname: String,
        path: String,
        mimetype: String,
        size: Number
    },
    readBy: [{
        userId: String,
        username: String,
        readAt: Date
    }],
    isDeleted: {
        type: Boolean,
        default: false
    },
    deletedBy: {
        userId: String,
        username: String,
        deletedAt: Date
    }
}, {
    timestamps: true
});

module.exports = mongoose.model('Message', messageSchema); 